package com.baizhiedu.bean;

import org.springframework.beans.factory.FactoryBean;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 * ClassName: ConnectionFactoryBean
 * Description:
 * Date: 2022/12/03 PM 9:22:43
 * <p>
 * project: spring5
 * package: com.baizhiedu.bean
 * email: 1085844536@qq.com
 * version:
 *
 * @author WangGuojian
 */
public class ConnectionFactoryBean implements FactoryBean<Connection> {

    @Override
    public Connection getObject() throws Exception {
        Class.forName("com.mysql.jdbc.Driver");
        return DriverManager.getConnection("jdbc:mysql://localhost:3306/wgj?useSSL=false"
                , "root", "123456");
    }

    @Override
    public Class<?> getObjectType() {
        return Connection.class;
    }

    @Override
    public boolean isSingleton() {
        return false;
    }
}
